<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加订单</title>
    <link rel="stylesheet" href="<%=basePath %>web/themes/icon.css">
    <link rel="stylesheet" href="<%=basePath %>web/themes/default/easyui.css">
    <link rel="stylesheet" href="<%=basePath %>web/css/wu.css">
	<script src="<%=basePath %>web/js/jquery.min.js"></script>
    <script src="<%=basePath %>web/js/jquery.easyui.min.js"></script>
    <script src="<%=basePath %>web/js/easyui-lang-zh_CN.js"></script>
    <script>
    	$(function(){
    	   var path=$("#path").val();
    		 $("#partList").datagrid({
                url:path+'part/getByCode',
                queryParams:{code:$("#code").val()},
                checkOnSelect:true,
                rownumbers:true,
                columns:[[
                    {field:'code',title:'询价编号',width:130},
                    {field:'partName',title:'配件名称',width:180},
                    {field:'partBrand',title:'配件品牌',width:120},
                    {field:'partNo',title:'配件型号',width:100},
                    {field:'amount',title:'数量',width:100
                    	
                    },
                    {field:'sellPrice',title:'单价',width:100, 
                        formatter:function(value,row,index){
                        	if(row.sellPrice==null){
                        		return "";
                        	}
                            return "￥"+row.sellPrice;
                        }
                    },
                    {field:'price',title:'总金额',width:100,
                         formatter:function(value,row,index){
                            return "￥"+row.price;
                        }
                    },
                    {field:'pd_memo',title:'备注',width:175},
                    {field:'sellPrice',title:'上次价格',width:220,
                    formatter:function(value,row,index){
                   			 if(row.sellPrice==null){
                        		return "";
                        	}
                            return "￥"+row.sellPrice;
                        }
                    }

                ]],
                   onLoadSuccess:function(){
	                $("#partList").datagrid('appendRow',{
	                	  'partBrand':"合计",
	                	  'amount':total('amount'),
	                	  'price':total('price')
	                   });
                    }
             });
    	})
    	
    	 function total(col){
        	var rows=$("#partList").datagrid('getRows');
        	var total=0;
        	for(var i=0;i<rows.length;i++){
        		total+=parseFloat(rows[i][col]);
        	}
        	return total;
        }
        function loadPart() {
            $("#partList").dialog({
                title: '选择配件',
                width: 1000,
                height: 400,
                closed: false,
                cache: false,
                modal: true,
           })
        } 
          function closePart() {
            $("#partList").dialog("destroy");
        }
         function closeDg(name) {
            $("#supplierName").val(name);
            $("#list").dialog("close");
        }  
        function add(){
        var path=$("#path").val();
          	parent.addTabs("添加订单",path+"web/goods/addOrderBill.jsp");
   
        }
         function loadClose(){
        	parent.closeTabs('查看订单')
        }    
    </script>
    <style>
        body {
            font-size:12px;
            padding:10px
        }
        .l-table-edit {
          border-collapse:collapse;
          border-spacing:0;
        }
        .l-table-edit-td {
            padding:4px;
            font-size:12px;
            border:1px solid #84a0c4 
        }
        
        
    </style>


</head>
<body>
<form name="form"  id="form" action="" method="post">
    <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width:100%;" border="1">
        <tr >
            <td width="17%"  align="right" class="l-table-edit-td">订单编号：</td>
            <td width="27%" align="left" class="l-table-edit-td">
           	    <input  type="text" class="easyui-textbox" id="code" value="${list.code }"  maxlength="100" ltype="text" style="height:20px" readonly="readonly" />
            </td>
            <td width="13%"  align="right" class="l-table-edit-td">订单日期：</td>
            <td width="43%" align="left" class="l-table-edit-td"><input  type="text" id="addDate" value="<fmt:formatDate value="${list.orderTime}" pattern="yyyy-MM-dd hh:mm:ss"/>" maxlength="30" class="easyui-datetimebox" style="height:20px" readonly="readonly"/></td>
        </tr>
        <tr>
            <td width="17%" align="right" class="l-table-edit-td">
                <a href="javascript:void(0)" style="color: blue;text-decoration: underline;">供应商名：</a>
            </td>
            <td align="left" class="l-table-edit-td" width="27%">
      
                <input type="text" id="supplierName"  value="${list.supplierName }" class="easyui-textbox"  maxlength="100" ltype="text"  style="height:20px" readonly="readonly"/>
            
            <td width="13%" align="right" class="l-table-edit-td">联系人员：</td>
            <td align="left" class="l-table-edit-td" width="43%">
                <input name="" type="text" id="contacter" value="${list.linkman }" class="easyui-textbox" maxlength="30" ltype="text" style="height:20px" readonly="readonly"/></td>
        </tr>
        <tr>
            <td width="17%" align="right" class="l-table-edit-td">电话：</td>
            <td width="27%" align="left" class="l-table-edit-td"><input  type="text" id="phone"class="easyui-textbox" value="${list.phone}"  maxlength="50" ltype="text" style="height:20px" readonly="readonly"/></td>
            <td width="13%" align="right" class="l-table-edit-td">传真：</td>
            <td width="43%" align="left" class="l-table-edit-td"><input type="text" id="fax" class="easyui-textbox" value="${list.company.fax }" maxlength="50"  ltype="text" style="height:20px" readonly="readonly"/></td>
        </tr>
        <tr>
            <td width="17%" align="right" class="l-table-edit-td">运输方式：</td>
            <td width="27%" align="left" class="l-table-edit-td">
             <select name="shippingMode" id="shippingMode" class="easyui-combobox" style="width:100px;height:20px" panelHeight="150px" disabled="disabled">
             		<c:if test="${list.shippingMode==1 }">
             		  	<option value="1" selected="selected">圆通快递</option> 
             		</c:if>
             		<c:if test="${list.shippingMode==2 }">
             		  	<option value="2" selected="selected" >中通快递</option> 
             		</c:if>
             </select>
            </td>
            <td width="13%" align="right" class="l-table-edit-td">业务人员：</td>
            <td width="43%"align="left" class="l-table-edit-td"><input type="text"  class="easyui-textbox"  id="fax" value="admin" maxlength="50"  ltype="text" style="height:20px" readonly="readonly"/></td>
        </tr>
        <tr>
            <td width="17%" align="right" class="l-table-edit-td">备注：</td>
            <td width="27%" align="left" class="l-table-edit-td"><input  type="text" class="easyui-textbox" id="type" value="${list.memo }" maxlength="50" ltype="text" style="height:20px" readonly="readonly"/></td>
            <td width="13%" align="right" class="l-table-edit-td">交货日期：</td>
            <td width="43%" align="left" class="l-table-edit-td"><input type="text"  class="easyui-datetimebox" id="fax" value="<fmt:formatDate value="${list.deliveryTime}" pattern="yyyy-MM-dd hh:mm:ss"/>" maxlength="50"  ltype="text" style="height:20px" readonly="readonly"/></td>
        </tr>
    </table>
</form>
<br>
<input type="hidden" id="path" value="<%=basePath%>"/>
<input  type="button" value="新   增" style="width:60px" onclick="add()">
<input  type="button" value="选询价单" style="width:60px" disabled="disabled">
<a href="javascript:loadPart()"><input  type="button" value="添加配件" style="width:60px" disabled="disabled"></a>
<input  type="button" value="保存" style="width:60px" disabled="disabled">
<input  type="button" value="审核" style="width:60px" disabled="disabled">
<a href="javascript:loadClose()"><input  type="button" value="关闭" style="width:60px" ></a>
<div id="list"  style="display: none" >
    <iframe src='<%=basePath %>web/goods/purchaseOrderBill_supplier.jsp' frameborder='0'style='width: 100%;height: 100%'></iframe>
</div>
<div id="partList"  style="display: none">
    <iframe src='<%=basePath %>web/goods/purchaseOrderBill_Part.jsp' frameborder='0'style='width: 100%;height: 100%'></iframe>
</div>
</body>
</html>